package com.ljs.controller;

import com.ljs.entity.Menu;
import com.ljs.entity.Order;
import com.ljs.responsitory.OrderMapper;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderHaddler {
    @Resource
    OrderMapper orderMapper;
    //添加订单的方法
    @RequestMapping("/insertOrder")
    public void insertorder(@RequestBody Order order){
        System.out.println("feign的order"+order);
        order.setDate(new Date());


        orderMapper.insertOrder(order);
    }
    //查找全部数据
    @RequestMapping("/sel/{uid}/{index}/{limit}")
    public List<Order> selorder (@PathVariable("index") int index, @PathVariable("limit") int limit,@PathVariable("uid") int uid){
        return orderMapper.selOrderbyUid(uid,index,limit);
    }
    @RequestMapping("/count/{uid}")//根据用户ID来查找数量
    public int count(@PathVariable("uid")int uid){
        return orderMapper.countbyUid(uid);
        }

}
